﻿using System;

namespace KryptecizerBase.Encryption
{
    /// <summary>
    /// Abstract Decryptor class to deviate futher encryptors.
    /// </summary>
    public abstract class Encryptor
    {
        #region abstract methods
        /// <summary>
        /// Abstract encryption mthod.
        /// </summary>
        public abstract void Encrypt();
        #endregion

        #region protected methods
        /// <summary>
        /// Called when [encryption startet].
        /// </summary>
        protected void OnEncryptionStartet()
        {
            if (EncryptionStartet != null)
                EncryptionStartet();
        }

        /// <summary>
        /// Called when [encryption ended].
        /// </summary>
        /// <param name="successful">if set to <c>true</c> [successful].</param>
        protected void OnEncryptionEnded(bool successful)
        {
            if (EncryptionEnded != null)
                EncryptionEnded(successful);
        }

        /// <summary>
        /// Called when [encryption processing].
        /// </summary>
        /// <param name="percentDone">The percent done.</param>
        protected void OnEncryptionProcessing(int percentDone)
        {
            if (EncryptionProcessing != null)
                EncryptionProcessing(percentDone);
        }
        #endregion

        #region Events and Delegates
        /// <summary>
        /// Handles EncryptionStartet event.
        /// </summary>
        public delegate void EncryptionStartedEventHandler();
        /// <summary>
        /// Occurs when [encryption startet].
        /// </summary>
        public event EncryptionStartedEventHandler EncryptionStartet;

        /// <summary>
        /// Handles EncryptionProcessing event.
        /// </summary>
        public delegate void EncryptionProcessingEventHandler(int percentDone);
        /// <summary>
        /// Occurs when [encryption processing].
        /// </summary>
        public event EncryptionProcessingEventHandler EncryptionProcessing;

        /// <summary>
        /// Handles EncryptionEnded event.
        /// </summary>
        public delegate void EncryptionEndedEventHandler(bool successful);
        /// <summary>
        /// Occurs when [encryption ended].
        /// </summary>
        public event EncryptionEndedEventHandler EncryptionEnded;
        #endregion
    }
}
